package com.qf.util;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.UUID;

/**
 * @Author AzureSky_X
 * @Date 2020/11/16 22:32
 * @Version 1.0
 */
public class CodeUtil {
    public static String getUUIDCode(){
        UUID uuid=UUID.randomUUID();
        String replace=uuid.toString().replace("-","");
        return replace;
    }
    /**
     * 这是生成随机订单编号的方法
     * @return
     */
    public static String getOrderNum(){
        SimpleDateFormat sdf=new SimpleDateFormat("yyyyMMddHHmmss");
        Date d=new Date();
        String format = sdf.format(d);
        //[0,1)*9000==>[0,9000),+1000
        //[1000~10000)
        int randomNum=(int)(Math.random()*9000+1000);
        return format+randomNum;
    }
}


